package com.miku.blog.service.impl;

import com.miku.blog.domain.pojo.ResponseResult;
import com.miku.blog.service.LogoutService;
import com.miku.blog.utils.GenerateKeyUtils;
import com.miku.blog.utils.RedisCache;
import com.miku.blog.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author shkstart
 * @create ${}YEAR-05-28 8:24
 */
@Service
public class LogoutServiceImpl implements LogoutService {

    @Autowired
    private RedisCache redisCache;

    @Override
    public ResponseResult logout() {

        String redisUserCacheKey = GenerateKeyUtils.getRedisUserCacheKey(SecurityUtils.getUserAuth().getId());
        String loginUserKey = redisCache.getCacheObject(redisUserCacheKey);
        redisCache.delCacheObject(redisUserCacheKey);
        redisCache.delCacheObject(loginUserKey);

        return ResponseResult.ok();

    }

}
